﻿@model ShipmentModel
@using Telerik.Web.Mvc.UI;
@using Nop.Core.Domain.Tax;
@using Nop.Core.Domain.Catalog;
@{    
    //page title
    ViewBag.Title = T("Admin.Orders.Shipments.ViewDetails").Text;
}
@using (Html.BeginForm())
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/subsites/Administration/Content/images/ico-sales.png")" alt="" />
            @T("Admin.Orders.Shipments.ViewDetails") - @Model.Id @Html.ActionLink("(" + T("Admin.Orders.Shipments.BackToOrder") + ")", "Edit", new { id = Model.OrderId })
        </div>
        <div class="options">
            @if (Model.DisplayPdfPackagingSlip)
            {
                //<a href="@Url.Action("PdfPackagingSlip", new { shipmentId = Model.Id })" class="t-button">@T("Admin.Orders.Shipments.PrintPackagingSlip")</a>
                <a href="@Url.Action("PrintPackageWaybillAsPdf", new { shipmentId = Model.Id })" class="t-button">@T("Admin.Orders.Shipments.PrintPackagingSlip")</a>
            }
            <span id="shipment-delete" class="t-button">@T("Admin.Common.Delete")</span>
        </div>
    </div>    
    @Html.ValidationSummary(false)
    <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.TrackingNumber):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.TrackingNumber)
                <input type="submit" name="settrackingnumber" value="@T("Admin.Orders.Shipments.TrackingNumber.Button")" id="settrackingnumber" class="adminButton" />
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.TotalWeight):
            </td>
            <td class="adminData">
                @Model.TotalWeight
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.ShippedDate):
            </td>
            <td class="adminData">
                @Model.ShippedDate
                @if (Model.CanShip)
                {
                    <input type="submit" name="setasshipped" value="@T("Admin.Orders.Shipments.ShippedDate.Button")" id="setasshipped" class="adminButton" />
                }
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.DeliveryDate):
            </td>
            <td class="adminData">
                @Model.DeliveryDate
                @if (Model.CanDeliver)
                {
                    <input type="submit" name="setasdelivered" value="@T("Admin.Orders.Shipments.DeliveryDate.Button")" id="setasdelivered" class="adminButton" />
                }
            </td>
        </tr>
    </table>
    if (Model.Products != null && Model.Products.Count > 0)
    {    @*Show shipment order product variant *@
        <table class="adminContent" width="100%">
            <tr class="adminSeparator">
                <td colspan="2">
                    <hr />
                </td>
            </tr>
            <tr>
                <td>
                    @* Hiding grid table's refresh button *@ 
                    @Html.Telerik().ScriptRegistrar().OnDocumentReady("$('#shipment-productvariants-grid .t-status').hide();")

                    @(Html.Telerik().Grid(Model.Products)
                        .Name("shipment-productvariants-grid")
                        .Columns(columns =>
                        {
                            columns.Bound(x => x.Id).Centered();
                            columns.Bound(x => x.FullProductName)
                                .Template(x => Html.ActionLink(x.FullProductName, "Edit", "ProductVariant", new { id = x.ProductVariantId }, new { }))
                                .ClientTemplate("<a href=\"" + @Url.Content("~/Admin/ProductVariant/Edit/") + "<#= ProductVariantId #>\">" + "<#= FullProductName #>" + "</a>")
                                .Centered()
                                .HeaderTemplate(T("Admin.Orders.Products.ProductName").Text);
                            columns.Bound(x => x.OrderProductVariantId).Centered();
                            columns.Bound(x => x.ProductVariantId).Centered();
                            columns.Bound(x => x.Sku).Centered();
                            columns.Bound(x => x.AttributeInfo).Centered();
                            columns.Bound(x => x.QuantityInThisShipment)
                                .Centered()
                                .Title(T("Admin.Orders.Products.Quantity").Text);
                        })
                        .Pageable(settings => settings.PageSize(Model.Products.Count).Position(GridPagerPosition.Both)))
                </td>
            </tr>
        </table>
    }
}
@Html.DeleteConfirmation("DeleteShipment", "shipment-delete")